package com.sdcqjy.property.mode;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

/**
 * Created by 磁磁帅 on 2018/3/31.
 * 功能：
 */

public class ListMsgMode implements Parcelable {
    /**
     * id : 34
     * documentName : 第十个项目
     * documentDesc : 哈哈呵呵呵
     * documentContent : 312412515125
     * documentCode :
     * categoryName : 网络竞价
     * categoryCode :
     * categoryID : 6
     * projectID : 1
     * projectCode : 0
     * projectName : 山东产权交易所
     * taxPrice :
     * finishDate : 0
     * projectStatus : 313123
     * actionTime : 20180406131426
     * action : null
     * createTime : 20180406131426
     * createby :
     * actionBy :
     * documentRealName : 山东方圆建筑工程检测中心所属鲁AHA971别克轿车
     * documentPath : /leinuo/resource/（暂定）济南璞园置业有限公司50%国有股权及95587.59万元债权.docx
     * imagePath :
     * htmlPath : http://39.107.247.32:8081/1522991663064.html
     */
    @SerializedName("documentName")
    public String title;
    public long createTime;
    public String id;
    public String documentDesc;
    public String documentContent;
    public String documentCode;
    public String categoryName;
    public String categoryCode;
    public int categoryID;
    public int isAttention;
    public int isRead;
    public long projectID;
    public String projectCode;
    public String projectName;
    public String taxPrice;
    public long finishDate;
    public String projectStatus;
    public long actionTime;
    public String action;
    public String createby;
    public String actionBy;
    public String documentRealName;
    public String documentPath;
    public String imagePath;
    public String htmlPath;

    private transient String time;
    private transient String finishTime;

    public String getTime() {
        if (TextUtils.isEmpty(time)) {
            //20180406131426
            String s = createTime + "";
            if (s == null || s.length() < 8) s = "00000000";
//            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//            time = format.format(createTime);
            time = s.substring(0, 4) + "-" + s.substring(4, 6) + "-" + s.substring(6, 8);
        }
        return time;
    }

    public String getFinishTime() {
        if (TextUtils.isEmpty(finishTime)) {
            String s = finishDate + "";
            if (s == null || s.length() < 8) s = "00000000";
            finishTime = s.substring(0, 4) + "-" + s.substring(4, 6) + "-" + s.substring(6, 8);
        }
        return finishTime;
    }

    public String getCategoryID() {
        String type[] = {"企业产股权", "企业增资扩股", "股权", "增资", "实物资产", "网络竞价"};
        int idx = categoryID - 1;
        if (idx < 0) idx = 0;
        else if (idx >= type.length) idx = type.length - 1;
        return type[idx];
    }

    public ListMsgMode() {
    }

    protected ListMsgMode(Parcel in) {
        title = in.readString();
        createTime = in.readLong();
        id = in.readString();
        documentDesc = in.readString();
        documentContent = in.readString();
        documentCode = in.readString();
        categoryName = in.readString();
        categoryCode = in.readString();
        categoryID = in.readInt();
        projectID = in.readLong();
        projectCode = in.readString();
        projectName = in.readString();
        taxPrice = in.readString();
        finishDate = in.readLong();
        projectStatus = in.readString();
        actionTime = in.readLong();
        action = in.readString();
        createby = in.readString();
        actionBy = in.readString();
        documentRealName = in.readString();
        documentPath = in.readString();
        imagePath = in.readString();
        htmlPath = in.readString();
        isAttention= in.readInt();
        isRead= in.readInt();
    }

    public static final Creator<ListMsgMode> CREATOR = new Creator<ListMsgMode>() {
        public ListMsgMode createFromParcel(Parcel in) {
            return new ListMsgMode(in);
        }

        public ListMsgMode[] newArray(int size) {
            return new ListMsgMode[size];
        }
    };

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(title);
        dest.writeLong(createTime);
        dest.writeString(id);
        dest.writeString(documentDesc);
        dest.writeString(documentContent);
        dest.writeString(documentCode);
        dest.writeString(categoryName);
        dest.writeString(categoryCode);
        dest.writeInt(categoryID);
        dest.writeLong(projectID);
        dest.writeString(projectCode);
        dest.writeString(projectName);
        dest.writeString(taxPrice);
        dest.writeLong(finishDate);
        dest.writeString(projectStatus);
        dest.writeLong(actionTime);
        dest.writeString(action);
        dest.writeString(createby);
        dest.writeString(actionBy);
        dest.writeString(documentRealName);
        dest.writeString(documentPath);
        dest.writeString(imagePath);
        dest.writeString(htmlPath);
        dest.writeInt(isAttention);
        dest.writeInt(isRead);
    }
}
